package com.mgg.common.util;

import com.mgg.common.enums.BaseResult;
import org.apache.commons.collections.MapUtils;

import com.mgg.common.enums.ResultEnum;
import com.mgg.common.vo.ResultVO;

/**
 * @Author: lijun
 * @Date: 2018-09-01 10:22:00
 */
public class ResultVOUtil {
	
    public static ResultVO success(Object object) {
        ResultVO resultVO = new ResultVO();
        resultVO.setData(object);
        resultVO.setCode(ResultEnum.SUCCESS.getCode());
        resultVO.setMessage(ResultEnum.SUCCESS.getMessage());
        return resultVO;
    }

    public static ResultVO success() {
        return success(MapUtils.EMPTY_MAP);
    }
    
    public static ResultVO error(BaseResult result) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(result.getCode());
        resultVO.setMessage(result.getMessage());
        resultVO.setData(MapUtils.EMPTY_MAP);
        return resultVO;
    }

    public static ResultVO error(String code, String msg) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(code);
        resultVO.setMessage(msg);
        resultVO.setData(MapUtils.EMPTY_MAP);
        return resultVO;
    }
}
